commonlibsse_ng\re\e/
ExtraAshPileRef.rs

1//! # ExtraAshPileRef
2//!
3//! This module defines the `ExtraAshPileRef` struct, which inherits from `BSExtraData` and represents
4//! extra data for ash pile references in Skyrim's engine. It includes a virtual table for C++ compatibility
5//! and maintains the original memory layout.
6
7use crate::re::BSExtraData::DerivedBSExtraData;
8use crate::re::BSPointerHandle::ObjectRefHandle;
9use crate::re::offsets_rtti::RTTI_ExtraAshPileRef;
10use crate::re::offsets_vtable::VTABLE_ExtraAshPileRef;
11use crate::re::{BSExtraData::BSExtraData, ExtraDataType::ExtraDataType};
12use crate::rel::id::VariantID;
13
14/// Represents extra data for an ash pile reference.
15#[repr(C)]
16pub struct ExtraAshPileRef {
17    /// Base class `BSExtraData`.
18    pub __base: BSExtraData,
19
20    /// The object reference handle pointing to the ash pile.
21    /// - Offset: `0x10`
22    pub ashPileRef: ObjectRefHandle,
23
24    /// Padding to maintain memory alignment.
25    /// - Offset: `0x14`
26    pub pad14: u32,
27}
28
29const _: () = {
30    assert!(core::mem::offset_of!(ExtraAshPileRef, __base) == 0x0);
31    assert!(core::mem::offset_of!(ExtraAshPileRef, ashPileRef) == 0x10);
32    assert!(core::mem::offset_of!(ExtraAshPileRef, pad14) == 0x14);
33    assert!(core::mem::size_of::<ExtraAshPileRef>() == 0x18);
34};
35
36impl Default for ExtraAshPileRef {
37    #[inline]
38    fn default() -> Self {
39        Self::new()
40    }
41}
42
43impl DerivedBSExtraData for ExtraAshPileRef {
44    #[inline]
45    fn get_extra_data(&self) -> &BSExtraData {
46        &self.__base
47    }
48
49    #[inline]
50    fn get_extra_data_type() -> ExtraDataType {
51        Self::EXTRA_DATA_TYPE
52    }
53}
54
55impl ExtraAshPileRef {
56    /// Address & Offset of the runtime type information (RTTI) identifier.
57    pub const RTTI: VariantID = RTTI_ExtraAshPileRef;
58
59    /// Address & Offset of the virtual function table.
60    pub const VTABLE: [VariantID; 1] = VTABLE_ExtraAshPileRef;
61
62    /// The `ExtraDataType` value for ash pile references.
63    pub const EXTRA_DATA_TYPE: ExtraDataType = ExtraDataType::AshPileRef;
64
65    /// Creates a new `ExtraAshPileRef` instance with default values.
66    ///
67    /// - `__base`: Default `BSExtraData`
68    /// - `ash_pile_ref`: Default `ObjectRefHandle`
69    /// - `pad14`: Zeroed padding
70    #[inline]
71    pub fn new() -> Self {
72        Self { __base: BSExtraData::new(), ashPileRef: ObjectRefHandle::default(), pad14: 0 }
73    }
74
75    /// Creates a new `ExtraAshPileRef` instance with a specific `ObjectRefHandle`.
76    ///
77    /// - `ash_pile_ref`: The reference handle pointing to the ash pile.
78    ///
79    /// # Returns
80    /// An instance of `ExtraAshPileRef` with the specified reference handle.
81    #[inline]
82    pub const fn with_ref(ash_pile_ref: ObjectRefHandle) -> Self {
83        Self { __base: BSExtraData::new(), ashPileRef: ash_pile_ref, pad14: 0 }
84    }
85
86    /// Retrieves the extra data type, always returning `ExtraDataType::kAshPileRef`.
87    ///
88    /// # Returns
89    /// - `ExtraDataType::kAshPileRef`
90    #[inline]
91    pub const fn get_type(&self) -> ExtraDataType {
92        ExtraDataType::AshPileRef
93    }
94}
95
96/// The virtual function table for `ExtraAshPileRef`.
97///
98/// This struct defines function pointers to simulate the C++ virtual functions.
99#[repr(C)]
100pub struct ExtraAshPileRefVtbl {
101    /// Destructor function pointer.
102    pub CxxDrop: fn(this: &mut ExtraAshPileRef),
103
104    /// Function pointer for retrieving the extra data type.
105    pub GetType: fn(this: &ExtraAshPileRef) -> ExtraDataType,
106
107    /// Function pointer for equality check.
108    pub IsNotEqual: fn(this: &ExtraAshPileRef, rhs: &ExtraAshPileRef) -> bool,
109}
110
111impl Default for ExtraAshPileRefVtbl {
112    #[inline]
113    fn default() -> Self {
114        Self::new()
115    }
116}
117
118impl ExtraAshPileRefVtbl {
119    /// Creates a new default virtual table with stubbed functions.
120    #[inline]
121    pub const fn new() -> Self {
122        const fn CxxDrop(_this: &mut ExtraAshPileRef) {}
123
124        const fn GetType(_this: &ExtraAshPileRef) -> ExtraDataType {
125            ExtraAshPileRef::EXTRA_DATA_TYPE
126        }
127
128        const fn IsNotEqual(_this: &ExtraAshPileRef, _rhs: &ExtraAshPileRef) -> bool {
129            false
130        }
131
132        Self { CxxDrop, GetType, IsNotEqual }
133    }
134}